Skip to content

feat: Phase 4 API routes (validate, export, history, cancel, delete)#7

Merged
prosdev merged 5 commits intomainfrom
feat/phase-4-api-routes
Mar 14, 2026
Merged

feat: Phase 4 API routes (validate, export, history, cancel, delete)#7
prosdev merged 5 commits intomainfrom
feat/phase-4-api-routes

Conversation

@prosdev
Copy link
Contributor

@prosdev prosdev commented Mar 14, 2026

Summary

  • Validate endpointPOST /v1/graphs/{id}/validate checks schema without executing. Returns 200 with valid:true or 422 with error details and node refs. Uses FakeListChatModel to avoid requiring LLM API keys during validation.
  • Export stubGET /v1/graphs/{id}/export returns 501 until Phase 5 implements code generation.
  • Run historyGET /v1/graphs/{id}/runs and GET /v1/runs with pagination (limit/offset), Literal status filter, and owner isolation.
  • CancelPOST /v1/runs/{id}/cancel returns 202. Handles both live runs (via RunManager) and stale DB runs (server restart recovery).
  • DeleteDELETE /v1/runs/{id} returns 204. Rejects active runs with 409.
  • Migration 003 — Composite indexes on runs table for history query performance.
  • Bug fixcancel_run() now also sets resume_event, fixing a hang when cancelling paused runs.

Test plan

Unit tests (240 total, all passing)

  • 9 new CRUD tests: pagination, offset, status filter, owner isolation, cross-graph listing, delete success/wrong-owner
  • 7 new validate/export route tests: valid schema, missing start, unknown tool with node_ref, not found, wrong owner, export 501, export not found
  • 14 new history/cancel/delete route tests: empty list, paginated, status filter, not found, wrong owner, global list, graph_id filter, owner exclusion, cancel running, cancel completed (409), cancel stale DB, cancel not found, delete completed, delete active (409)
  • 3 updated migration tests: version bumped to 3, bad migration test uses VERSION=4

Manual tests (19-29, all passing)

# Test What it verifies
19 Validate then run Valid schema → validate 200 → run completes successfully
20 Validate error types Missing start (422), unknown tool with node_ref (422), graph not found (404)
21 Export stub Returns 501 with detail message, 404 for missing graph
22 Run history mixed 3 runs (2 completed, 1 cancelled) → correct statuses in list, per-graph filtering
23 Pagination 12 runs → 3 pages (5+5+2), no duplicate IDs across pages
24 Status filter Mixed statuses → filter each, verify totals match, paused=0
25 Cancel paused run Start → pause → cancel 202 → status becomes error → appears in history
26 Cancel stale DB run Insert "running" in DB → cancel 202 → DB updated to error with "server lost"
27 Delete completed Insert → verify in history → delete 204 → gone from history and status
28 Delete active rejected Pause → delete 409 → cancel → delete 204 → verify gone
29 Full lifecycle validate → export 501 → run → history → cancel → delete → history empty

Notable findings during testing

  • cancel_run() only set cancel_event but not resume_event, causing paused runs to hang on cancel — fixed by setting both
  • Tool-only graphs complete too fast to test cancel mid-run — tests use human_input graphs that stay paused
  • POST validate requires Content-Type: application/json due to middleware enforcement — tests send json={}

🤖 Generated with Claude Code

prosdev and others added 5 commits March 14, 2026 13:37
Add detailed plan for validate, export stub, run history,
cancel, and delete endpoints. Update plan READMEs to reflect
Phase 3 merged and Phase 4 in progress.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upgrade list_runs_by_graph with offset/total/status filter.
Add list_runs for cross-graph queries. Add delete_run.
Add migration 003 with composite indexes for run history queries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
POST /v1/graphs/{id}/validate checks schema without executing.
Returns 200 with valid:true or 422 with error details and node refs.
GET /v1/graphs/{id}/export returns 501 until Phase 5.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GET /v1/graphs/{id}/runs lists paginated runs with status filter.
GET /v1/runs lists all runs for the authenticated owner.
POST /v1/runs/{id}/cancel stops running/paused runs.
DELETE /v1/runs/{id} removes completed/error runs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add 11 manual test scripts (19-29) covering Phase 4 API routes:
validate, export stub, run history, pagination, status filter,
cancel paused, cancel stale, delete completed, delete active
rejected, and full lifecycle.

Fix cancel_run to also set resume_event, unblocking
_wait_for_resume so cancellation is detected during pause.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prosdev prosdev merged commit 3ec6f45 into main Mar 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant